<!-- 物料管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label">物料管理</p>
    <div class="btm mt10 pt10">
      <!-- <div class="mb10 display-flex">
        <div>
          <n-upload @before-upload="uploadxl" accept=".xls, .xlsx">
            <n-button type="info" :loading="dftte">导入</n-button>
          </n-upload>
        </div>
        <div class="dfssrra ml10">
          <n-button @click="downloadXLSX">下载模版</n-button>
        </div>
      </div> -->

      <dxtable
        :dataJson="dataJson"
        :portUrl="portUrl"
        :qx="qx"
        ref="databale"
        :formJson="formJson"
        :hidebj="true"
        :isshowXz="false"
        :headBtn="headBtnw"
        :showdr="true"
        drerrtext="物料导入模板内容不能为空，请修改后重试！"
        @initDataCall="initDataCall"
      ></dxtable>
    </div>
  </div>
</template>
 <script lang='ts' setup>
import dxtable from "../../../components/util/dxtable.vue";
import { dxget, dxpost, qurl, readExcel } from "../../../util/index";
import { h, ref, reactive } from "vue";
import { NButton } from "naive-ui";
const cz = qurl();
const dftte = ref();
const databale = ref();

const emit = defineEmits(["callBack"]);
// 弹窗公用该列表
let dataJson = reactive([
  {
    title: "物料号",
    key: "materialNumber",
  },
  {
    title: "尺寸",
    key: "size",
  },
  {
    title: "数量",
    key: "quantity",
  },
  {
    title: "描述",
    key: "describe",
  },

  {
    title: "添加时间",
    key: "addTime",
    width: "200",
    type: "daterange",
  },
]);
let portUrl = "kx/kxmaterialManagement?parentLevel=" + cz.id;
const qx = {
  DeletePermissionID: "kxmaterialManagementdel", //删除
  EditPermissionIdentifier: "kxmaterialManagementbj", // 编辑
  NewPermissionIdentifier: "kxmaterialManagementxz", // 新建
  ViewPermissionID: "kxmaterialManagementck", // 查看
};

let formJson = reactive([
  {
    title: "物料号",
    key: "materialNumber",
    type: "input",
    required: true,
  },
  {
    title: "尺寸",
    key: "size",
    type: "input",
    required: true,
  },
  {
    title: "数量",
    key: "quantity",
    required: true,
    type: "input",
  },
  {
    title: "描述",
    key: "describe",
    type: "input",
    required: true,
  },
]);

const downloadXLSX = () => {
  window.location.href =
    "https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/adminstatic/%E7%89%A9%E6%96%99%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx";
};
const headBtnw = ref([
  {
    name: "下载物料导入模板",
    jy: true,
    type: "default",
    clickFun: () => {
      downloadXLSX();
    },
  },
]);
const initDataCall = async (data) => {
  const jkjhe = data > 0 ? "2" : "1";
  dxpost(
    "kx/kxboxMsg",
    {
      id: cz.id,
      ImportMaterialsONot: jkjhe,
    },
    "put"
  );
};
</script>
 <style scoped>
</style>


